package com.catsic.pub.file.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.catsic.base.BaseServiceImpl;
import com.catsic.base.exception.CatsicException;
import com.catsic.pub.condition.FileUploadCondition;
import com.catsic.pub.constants.Constants;
import com.catsic.pub.entity.FileUpload;
import com.catsic.pub.exception.CatsicExceptionCode;
import com.catsic.pub.file.dao.FileUploadDao;
import com.catsic.pub.file.service.FileUploadService;
import com.catsic.pub.specification.FileUploadSpec;

@Service("fileService")
public class FileUploadServiceImpl extends BaseServiceImpl<FileUpload, String> implements
		FileUploadService {
	
	@Autowired
	private FileUploadDao fileDao;
/*
	@Override
	protected BaseDao<FileUpload, String> getEntityDao() {
		return fileDao;
	}*/

	@Override
	public FileUpload add(FileUpload file){
		return super.add(file);
	}
	
	@Override
	public FileUpload findById(String id) {
		FileUpload file = getById(id);
		if(null == file){
			throw new CatsicException(CatsicExceptionCode.实体不存在,Constants.FILE);
		}
		return file;
	}
	
	@Override
	public List<FileUpload> findByFid(String fid) {
		return fileDao.findByFid(fid);
	}

	@Override
	public List<FileUpload> findAll(FileUploadCondition condition) {
		FileUploadSpec spec = new FileUploadSpec(condition);
		return fileDao.findAll(spec);
	}
	
}
